package com.treasure.mall.biz.repository.community;

import com.treasure.mall.biz.base.JpaSearchableRepository;
import com.treasure.mall.biz.entity.community.CommunityCommentPO;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public interface CommunityCommentRepository extends JpaSearchableRepository<CommunityCommentPO, Long> {
    @Query("update CommunityCommentPO po set po.replyCount=po.replyCount+?2 where po.id=?1 and po.replyCount+?2>=0")
    @Modifying
    @Transactional
    void updateReplyCount(Long id, long count);

    @Query("update CommunityCommentPO po set po.likeCount=po.likeCount+?2 where po.id=?1 and po.likeCount+?2>=0")
    @Modifying
    @Transactional
    void updateLikeCount(Long id, long count);
}
